<?php
/**
 * App for managing companies
 * 
 * Template for company detail page
 * 
 * @category Abovo
 * 
 * @package Abovo_App_Crm
 * 
 * @subpackage Abovo_App_Crm_Companies
 * 
 * @license http://opensource.org/licenses/gpl-license.php GPL
 * 
 * @author Antti Holvikari <anttih@gmail.com>
 */
?>
<h2><?php echo $this->escape($this->company->name) ?></h2>

<div class="yui-g">
    <div class="yui-u first">
        <h3><?php echo $this->action['name'] ?></h3>
        <ul class="actions">
            <li class="first"><?php echo $this->action('crm/companies/edit/' . $this->company->id, $this->getText('ACTION_EDIT')) ?></li>
        </ul>
        <table class="list">
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_NAME') ?></th>
                <td><b><?php echo $this->escape($this->company->name) ?></b></td>
            </tr>
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_SHORT') ?></th>
                <td><?php echo $this->escape($this->company->short) ?></td>
            </tr>
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_VAT') ?></th>
                <td><?php echo $this->escape($this->company->vat) ?></td>
            </tr>
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_URL') ?></th>
                <td><a href="<?php echo $this->company->url ?>"><?php echo $this->company->url ?></a></td>
            </tr>
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_ADR') ?></th>
                <td>
                    <?php echo $this->escape($this->company->adr) ?><br />
                    <?php echo $this->escape($this->company->postal_code . ' '. $this->company->city) ?><br />
                    <?php echo $this->getText("Lux_Intl::COUNTRY_{$this->company->country}") ?>
                </td>
            </tr>
            <tr>
                <th><?php echo $this->getText('TEXT_ADR_SHIP') ?></th>
                <td>
                    <?php echo $this->escape($this->company->ship_adr) ?><br />
                    <?php echo $this->company->ship_postal_code ?> <?php echo $this->escape($this->company->ship_city) ?><br />
                    <?php echo $this->getText("Lux_Intl::COUNTRY_{$this->company->ship_country}") ?>
                </td>
            </tr>
            <tr>
                <th><?php echo $this->getText('LABEL_CREATED') ?></th>
                <td><?php echo $this->timestamp($this->company->created, $this->getText('FORMAT_TIMESTAMP')) ?></td>
            </tr>
            <tr>
                <th><?php echo $this->getText('Abovo_Model_Company::LABEL_UPDATED') ?></th>
                <td><?php echo $this->timestamp($this->company->updated, $this->getText('FORMAT_TIMESTAMP')) ?></td>
            </tr>
            <tr>
                <th><?php echo $this->getText('TEXT_TAGS', 2) ?></th>
                <td><?php echo $this->escape(implode(' ', $this->company->tags)) ?></td>
            </tr>
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Company', 'LABEL_DESCR') ?></th>
                <td><?php echo nl2br($this->escape($this->company->descr)) ?></td>
            </tr>
        </table>
    </div>
    
    <div class="yui-u">
        <h3>Contacts</h3>
        <ul class="actions">
            <li class="first"><?php echo $this->action('crm/contacts/add', $this->getText('Abovo_App_Crm_Contacts::APP_ACTION_ADD')) ?></li>
        </ul>
        <?php if (count($this->contacts) > 0): ?>
        <table class="list">
            <tr>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Contacts', 'LABEL_NAME') ?></th>
                <th><?php echo Solar::$locale->fetch('Abovo_Model_Contacts', 'LABEL_EMAIL') ?></th>
            </tr>
            <?php foreach ($this->contacts as $contact): ?>
                <tr>
                    <td>
                        <a href="<?php echo $this->action('crm/contacts/show/' . $this->escape($contact->id)) ?>">
                            <?php echo $this->escape($contact->lastname) ?>, <?php echo $this->escape($contact->firstname) ?>
                        </a>
                    </td>
                    <td><?php echo $this->escape($contact->email) ?></td>
                </tr>
            <?php endforeach; ?>
        </table>
        <?php else: ?>
            <?php echo $this->getText('TEXT_NO_CONTACTS') ?>
        <?php endif; ?>
    </div>
</div>